// $Id: log.h 2 2011-10-17 17:49:43Z cedric.shih@gmail.com $
/*
 * Copyright 2010 Cedric Shih (cedric dot shih at gmail dot com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef LOG_H_
#define LOG_H_

#include <stdarg.h>

#include "zcbuffer.h"

#define zcbuffer_trace(fmt...) zcbuffer_log(ZCBUFFER_TRACE, __func__, __LINE__, fmt)
#define zcbuffer_debug(fmt...) zcbuffer_log(ZCBUFFER_DEBUG, __func__, __LINE__, fmt)
#define zcbuffer_info(fmt...) zcbuffer_log(ZCBUFFER_INFO, __func__, __LINE__, fmt)
#define zcbuffer_warn(fmt...) zcbuffer_log(ZCBUFFER_WARN, __func__, __LINE__, fmt)
#define zcbuffer_error(fmt...) zcbuffer_log(ZCBUFFER_ERROR, __func__, __LINE__, fmt)
#define zcbuffer_fatal(fmt...) zcbuffer_log(ZCBUFFER_FATAL, __func__, __LINE__, fmt)

#ifdef __GNUC__
#define ZCBUFFER_CHECK_FMT(a,b) __attribute__((format(printf, a, b)))
#else
#define ZCBUFFER_CHECK_FMT(a,b)
#endif

void zcbuffer_log(enum zcbuffer_log_level level,
		const char *func, unsigned int line,
		const char *fmt, ...) ZCBUFFER_CHECK_FMT(4,5);

#endif /* LOG_H_ */
